package com.medistat.persistance.service.interfaces;

import java.util.Calendar;
import java.util.List;

import com.medistat.model.Department;
import com.medistat.model.Doctor;
import com.medistat.model.FreeDay;
import com.medistat.model.Holiday;
import com.medistat.model.Setting;
import com.medistat.model.StandardPersistentObject;
import com.medistat.model.User;
import com.medistat.model.WeekendDutiesInfo;
import com.medistat.model.Work;
import com.medistat.model.enums.Days;
import com.medistat.model.enums.TypeOfWork;
import com.medistat.model.enums.WeekendDutiesInfoCreationPurpose;

public interface PersistanceService {

	Department getDepartment(Long departmentId) throws Exception;
	//adding - for testing purposes
	void addDepartment(Department department) throws Exception;
	
	void addDoctor(Doctor doctor, Long departmentId) throws Exception;
	void updateDoctor(Doctor doctor) throws Exception;
	Doctor getDoctor(Long selectedDoctor) throws Exception;
	void deleteDoctor(Doctor doctor) throws Exception;
	Doctor findDoctor(String name, String surname) throws Exception;
	List<Doctor> getActiveDoctors();
	
	Doctor findDoctorFromSettings(Days dayInWeek, Integer weekInMonth, TypeOfWork typeOfWork);
	FreeDay findFreeDayForDoctorOn(Calendar date, Doctor doctor);
	
	void addSetting(Setting setting, Long departmentId) throws Exception;
	Setting getSetting(Long settingId) throws Exception;
	void deleteSetting(Setting setting) throws Exception;
	Setting findSetting(Days dayInWeek, Long doctorId, TypeOfWork typeOfWork, Integer weekInMonth);
	
	//adding is enabled for standard application(it should be enhance(visible only) with administrator permissions).
	void addUser(User user, Long departmentId) throws Exception;
	User getUser(String username, String password) throws Exception;
	void updateUser(User user) throws Exception;
	
	//for testing purpose only!!!
	void deleteUser(User user) throws Exception;
	
	void addHoliday(Holiday holiday) throws Exception;
	void deleteHoliday(Holiday holiday) throws Exception;
	List<Holiday> getAllHolidaysForMonth(Calendar firstDate);
	List<Holiday> getHolidaysForYear(Integer year);
	
	void addFreeDay(FreeDay freeDay, Long doctorId) throws Exception;
	void deleteFreeDay(FreeDay freeDay) throws Exception;
	List<FreeDay> getFreeDays(Calendar dateFrom, Calendar dateUntil) throws Exception;
	
	Work findWork(Calendar date, TypeOfWork typeOfWork);
	List<Work> findWorksBetween(Calendar dateFrom, Calendar dateTo);
	List<Work> getDutiesForMonth(Integer year, Integer month);
	List<Work> getDutiesForYear(Integer year);
	
	Work getWorkFor(Calendar date);
	
	<T extends StandardPersistentObject> List<T> getAll(Class<T> clazz);
	<T extends StandardPersistentObject> void saveAll(List<T> objects)	throws Exception;
	public <T extends StandardPersistentObject> void deleteObject(T object) throws Exception;
	
	void addWeekendDutiesInfo(WeekendDutiesInfoCreationPurpose weekendDutiesInfoCreationPurpose, String creationPurpose, Calendar creationDate) throws Exception;
	void updateWeekendDutiesInfo(Doctor doctor) throws Exception;
	List<WeekendDutiesInfo> getWeekendDutiesInfosWithMaxCreationDateForDoctors(List<Doctor> doctorsCache);
	WeekendDutiesInfo getWeekendDutiesInfo(Integer year, WeekendDutiesInfoCreationPurpose weekendDutiesInfoCreationPurpose);
}
